import request from '@/router/axios';
///////////////////////////////////////////bom///////////////////////////////////////

export const getList = (current, size, params) => {
  return request({
    url: '/api/mes-admin/bom/page',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

export const add = (row) => {
  return request({
    url: '/api/mes-admin/bom/submit',
    method: 'post',
    data: row
  })
}




//查询产品绑定工序 
export const getProcessList = (params) => {
  return request({
    url: '/api/mes-product/process/product-route/get-by-part-no',
    method: 'get',
    params
  })
}

export const remove = (id) => {
  return request({
    url: '/api/mes-admin/bom/remove',
    method: 'get',
    params: {
      id,
    }
  })
}

export const update = (row) => {
  return request({
    url: '/api/mes-admin/bom/submit',
    method: 'post',
    data: row
  })
}

///////////////////////////////////////////主物料清单///////////////////////////////////////


export const addPart= (row) => {
  return request({
    url: '/api/mes-admin/bom/detail/submit',
    method: 'post',
    data: row
  })
}

export const removePart = (ids) => {
  return request({
    url: '/api/mes-admin/bom/detail/remove',
    method: 'get',
    params: {
      ids,
    }
  })
}

export const getPartList = (params) => {
  return request({
    url: '/api/mes-admin/bom/detail/part-page',
    method: 'get',
    params
  })
}

export const updatePart= (row) => {
  return request({
    url: '/api/mes-admin/bom/detail/submit',
    method: 'post',
    data: row
  })
}

///////////////////////////////////////////替代料///////////////////////////////////////

export const getReplaceList = (params) => {
  return request({
    url: '/api/mes-admin/bom/detail/replace/list',
    method: 'get',
    params
  })
}


export const addReplace= (row) => {
  return request({
    url: '/api/mes-admin/bom/detail/replace/submit',
    method: 'post',
    data: row
  })
}

export const removeReplace = (ids) => {
  return request({
    url: '/api/mes-admin/bom/detail/replace/remove',
    method: 'get',
    params: {
      ids,
    }
  })
}

export const updateReplace = (row) => {
  return request({
    url: '/api/mes-admin/bom/detail/replace/submit',
    method: 'post',
    data: row
  })
}

/**
 * 启用
 */

export const disable = (id, partId) => {
  return request({
    url: `/api/mes-admin/bom/disable?id=${id}&bomId=${partId}`,
    method: 'get'
  });
}

/**
 * 禁用
 * @param {} id 
 * @param {*} bomId 
 * @returns 
 */
export const enable = (id, partId) => {
  return request({
    url: `/api/mes-admin/bom/enable?id=${id}&partId=${partId}`,
    method: 'get'
  });
}





